#!/usr/bin/python3

import os
import sys


def re_npmbuild(libspath, filep):
    path_cells = filep.split(os.sep)
    if path_cells.count("net"):
        path_net = os.path.join(libspath, "net")
        os.chdir(path_net)
        ret = os.system("npm run compile")
    elif path_cells.count("coreex"):
        path_net = os.path.join(libspath, "coreex")
        os.chdir(path_net)
        ret = os.system("npm run compile")


if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("params len is <2 ,raise error!")
        sys.exit()

    print("******************")
    print("*******build******")
    print("******************")
    libpath = sys.argv[1]
    file_chg = sys.argv[2]
    re_npmbuild(libpath, file_chg)
